#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, na, nb, sa = 0, sb = 0, la[205], lb[205], ma = 1, mb = 1;
    int a[5][5] = {{0, -1, 1, 1, -1},
                   {1, 0, -1, 1, -1},
                   {-1, 1, 0, -1, 1},
                   {-1, -1, 1, 0, 1},
                   {1, 1, -1, -1, 0}
    };
    cin >> n >> na >> nb;
    for (int i = 1; i <= na; i++){
        cin >> la[i];
    }
    for (int i = 1; i <= nb; i++){
        cin >> lb[i];
    }
    for (int i = 0; i < n; i++){
        int ra = la[ma];
        int rb = lb[mb];
        if (a[ra][rb] == 1) sa++;
        else if(a[ra][rb] == -1) sb++;
        ma++;
        mb++;
        if (ma > na) ma = 1;
        if (mb > nb) mb = 1;
    }
    cout << sa << " " << sb;
    return 0;
}